/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __8FDBA394_7DD4_4cc7_8F45_D92484718DF3__
#define __8FDBA394_7DD4_4cc7_8F45_D92484718DF3__


/////////////////////////////////////////////////////////////////////////////////////////
// 
namespace xos_box
{

    // 
    // i_list iter interface
    // 
    class i_list_iter : public xos::i_release
    {
    protected:
        virtual ~i_list_iter(){}

    public:
        virtual xos::i_release * next() = 0;
        virtual int reset() = 0;
    };

    // 
    // warning : thread not safe!!!
    // 
    // i_list interface.
    // 
    class i_list : public xos::i_release
    {
    protected:
        virtual ~i_list(){}

    public:
        // 
        // add data
        // 
        virtual int add_data( const char * lpszData, int nLen, bool bTail ) = 0;
        virtual int add_data( i_big_buf * pBuf, bool bTail ) = 0;
        virtual int add_data( i_buf * pBuf, bool bTail ) = 0;
        virtual int add_str( const char * lpszStr, bool bTail ) = 0;
        virtual int add_str( i_string * pStr, bool bTail ) = 0;

        // 
        // ret : get data len
        // 
        virtual int get_data( char * lpszData, int nLen ) = 0;
        virtual int get_data( i_big_buf * pBuf ) = 0;
        virtual int get_data( i_buf * pBuf ) = 0;

        // 
        // load/save file
        // 
        virtual int load( const char * lpszFile ) = 0;
        virtual int save( const char * lpszFile ) = 0;

        // 
        // back operation
        // 
        virtual int push_back( xos::i_release * pObj ) = 0;
        virtual xos::i_release * back( xos::i_release ** ppObj ) = 0;
        virtual int pop_back() = 0;

        // 
        // front operation
        // 
        virtual int push_front( xos::i_release * pObj ) = 0;
        virtual xos::i_release * front( xos::i_release ** ppObj ) = 0;
        virtual int pop_front() = 0;

        // 
        // remove with xos::i_release *
        // 
        virtual int remove( xos::i_release * pObj ) = 0;

        // 
        // point to next after remove.
        // 
        virtual xos::i_release * remove() = 0;

        // 
        // reset list iter
        // 
        virtual int reset() = 0;

        // 
        // null if to end
        // 
        virtual xos::i_release * next() = 0;

        // 
        // 得到list的前后向迭代器
        // 
        virtual i_list_iter * rbegin() = 0;
        virtual i_list_iter * begin() = 0;

        // 
        // some operation
        // 
        virtual int add_to_front( xos_box::i_list * pList ) = 0;
        virtual int add_to_tail( xos_box::i_list * pList ) = 0;
        virtual int swap( xos_box::i_list * pList ) = 0;
        virtual int copy( xos_box::i_list * pList ) = 0;

        virtual int release_all() = 0;
        virtual int clear() = 0;
        virtual int size() = 0;

        // 
        // unlock/lock
        // 
        virtual int un_lock() = 0;
        virtual int lock() = 0;
    };
}

#endif // __8FDBA394_7DD4_4cc7_8F45_D92484718DF3__
